package com.jzhao.jpre.security;

import org.springframework.dao.DataAccessException;

import com.jzhao.jpre.base.Assembler;
import com.jzhao.jpre.model.Device;
import com.jzhao.jpre.model.dao.DeviceDao;

public class AuthFromDB implements Authenticate {
	public boolean checkDevice(String IP, String devId)
	{
		DeviceDao deviceDao = (DeviceDao) Assembler.getInstance("deviceDao");
		Device device = new Device();
		try {
			device = deviceDao.selectByDevNo(devId);
			System.out.println("DevNo = " + device.getDevNo());
			System.out.println("DevIp = " + device.getDevIp());
		} catch (DataAccessException dae) {
			System.out.println("The record doesn't exist!");
			System.out.println(dae.getMessage());
			return false;
		}
		return true;
	}
}
